#!/usr/bin/env python3
# Create Rust files correctly

import os

# Create directories if they don't exist
src_dir = "src"
if not os.path.exists(src_dir):
    os.makedirs(src_dir)

# Content for token.rs
token_content = '''use std::fmt;

#[derive(Debug, Clone, PartialEq)]
pub enum TokenType {
    // Literals
    Identifier,
    IntegerLiteral,
    FloatLiteral,
    StringLiteral,
    BoolLiteral,
    
    // Keywords
    Package,
    Import,
    Class,
    Interface,
    Struct,
    Enum,
    Func,
    Let,
    Var,
    Const,
    Type,
    Init,
    This,
    Super,
    If,
    Else,
    Try,
    Catch,
    Finally,
    For,
    While,
    Do,
    Return,
    Break,
    Continue,
    Match,
    Case,
    Where,
    Extend,
    With,
    Prop,
    Static,
    Public,
    Private,
    Internal,
    Protected,
    Override,
    Redef,
    Abstract,
    Sealed,
    Open,
    Foreign,
    Inout,
    Mut,
    Unsafe,
    Operator,
    Spawn,
    Synchronized,
    Main,
    
    // Types
    Int8,
    Int16,
    Int32,
    Int64,
    IntNative,
    UInt8,
    UInt16,
    UInt32,
    UInt64,
    UIntNative,
    Float16,
    Float32,
    Float64,
    Rune,
    Boolean,
    Nothing,
    Unit,
    ThisType,
    VArray,
    
    // Operators
    Dot,
    Comma,
    LParen,
    RParen,
    LSquare,
    RSquare,
    LCurl,
    RCurl,
    Exp,
    Mul,
    Mod,
    Div,
    Add,
    Sub,
    Pipeline,
    Composition,
    Inc,
    Dec,
    And,
    Or,
    Not,
    BitAnd,
    BitOr,
    BitXor,
    BitNot,
    LShift,
    RShift,
    Colon,
    Semi,
    Assign,
    AddAssign,
    SubAssign,
    MulAssign,
    ExpAssign,
    DivAssign,
    ModAssign,
    AndAssign,
    OrAssign,
    BitAndAssign,
    BitOrAssign,
    BitXorAssign,
    LShiftAssign,
    RShiftAssign,
    Arrow,
    BackArrow,
    DoubleArrow,
    RangeOp,
    ClosedRangeOp,
    Ellipsis,
    Hash,
    At,
    Quest,
    Lt,
    Gt,
    Le,
    Ge,
    Is,
    As,
    NotEq,
    Equal,
    UpperBound,
    Wildcard,
    
    // Special
    Newline,
    Comment,
    EndOfFile,
    Illegal,
}

#[derive(Debug, Clone)]
pub struct Token {
    pub token_type: TokenType,
    pub value: String,
    pub line: usize,
    pub column: usize,
}

impl Token {
    pub fn new(token_type: TokenType, value: String, line: usize, column: usize) -> Self {
        Self {
            token_type,
            value,
            line,
            column,
        }
    }
}

impl fmt::Display for Token {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{}:{} - {:?} = "{}"", self.line, self.column, self.token_type, self.value)
    }
}
'''

# Write token.rs
with open(os.path.join(src_dir, "token.rs"), "w", encoding="utf-8") as f:
    f.write(token_content)

print("Created token.rs")

# Content for lib.rs
lib_content = '''pub mod token;

#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {
        assert_eq!(2 + 2, 4);
    }
}
'''

# Write lib.rs
with open(os.path.join(src_dir, "lib.rs"), "w", encoding="utf-8") as f:
    f.write(lib_content)

print("Created lib.rs")

print("Successfully created Rust files!")